package com.sun.common.core.excel.model;

import com.alibaba.excel.support.ExcelTypeEnum;

import java.io.InputStream;

/**
 * The type Read meta.
 *
 * @param <T> the type parameter
 * @author : Milo
 */
@SuppressWarnings(SuppressWarningConstant.UNUSED)
public class ReadMeta<T> {
    private InputStream excelStream;
    private Integer headRowNumber;
    private Class<T> clazz;
    private String password;
    private ExcelTypeEnum type = ExcelTypeEnum.XLSX;

    /**
     * Instantiates a new Read meta.
     */
    public ReadMeta() {
    }

    /**
     * Instantiates a new Read meta.
     *
     * @param builder the builder
     */
    public ReadMeta(final Builder<T> builder) {
        this.excelStream = builder.excelStream;
        this.headRowNumber = builder.headRowNumber;
        this.clazz = builder.clazz;
        this.password = builder.password;
        this.type = builder.type;
    }

    /**
     * Builder builder.
     *
     * @param <T> the type parameter
     * @return the builder
     */
    public static <T> Builder<T> builder() {
        return new Builder<>();
    }

    /**
     * Gets excel stream.
     *
     * @return the excel stream
     */
    public InputStream getExcelStream() {
        return this.excelStream;
    }

    /**
     * Sets excel output stream.
     *
     * @param excelStream the excel stream
     */
    public void setExcelOutputStream(final InputStream excelStream) {
        this.excelStream = excelStream;
    }

    /**
     * Gets head row number.
     *
     * @return the head row number
     */
    public Integer getHeadRowNumber() {
        return this.headRowNumber;
    }

    /**
     * Sets head row number.
     *
     * @param headRowNumber the head row number
     */
    public void setHeadRowNumber(final Integer headRowNumber) {
        this.headRowNumber = headRowNumber;
    }

    /**
     * Gets clazz.
     *
     * @return the clazz
     */
    public Class<T> getClazz() {
        return this.clazz;
    }

    /**
     * Sets clazz.
     *
     * @param clazz the clazz
     */
    public void setClazz(final Class<T> clazz) {
        this.clazz = clazz;
    }

    /**
     * Gets password.
     *
     * @return the password
     */
    public String getPassword() {
        return this.password;
    }

    /**
     * Sets password.
     *
     * @param password the password
     */
    public void setPassword(final String password) {
        this.password = password;
    }

    /**
     * Gets type.
     *
     * @return the type
     */
    public ExcelTypeEnum getType() {
        return this.type;
    }

    /**
     * Sets type.
     *
     * @param type the type
     */
    public void setType(final ExcelTypeEnum type) {
        this.type = type;
    }

    /**
     * The type Builder.
     *
     * @param <T> the type parameter
     */
    public static class Builder<T> {
        private InputStream excelStream;
        private Integer headRowNumber;
        private Class<T> clazz;
        private String password;
        private ExcelTypeEnum type = ExcelTypeEnum.XLSX;

        /**
         * Excel stream builder.
         *
         * @param excelStream the excel stream
         * @return the builder
         */
        public Builder<T> excelStream(final InputStream excelStream) {
            this.excelStream = excelStream;
            return this;
        }

        /**
         * Head row number builder.
         *
         * @param headRowNumber the head row number
         * @return the builder
         */
        public Builder<T> headRowNumber(final Integer headRowNumber) {
            this.headRowNumber = headRowNumber;
            return this;
        }

        /**
         * Clazz builder.
         *
         * @param clazz the clazz
         * @return the builder
         */
        public Builder<T> clazz(final Class<T> clazz) {
            this.clazz = clazz;
            return this;
        }

        /**
         * Password builder.
         *
         * @param password the password
         * @return the builder
         */
        public Builder<T> password(final String password) {
            this.password = password;
            return this;
        }

        /**
         * Type builder.
         *
         * @param type the type
         * @return the builder
         */
        public Builder<T> type(final ExcelTypeEnum type) {
            this.type = type;
            return this;
        }

        /**
         * Build read meta.
         *
         * @return the read meta
         */
        public ReadMeta<T> build() {
            return new ReadMeta<>(this);
        }
    }
}
